Hello, |
Re: identify OLE-position in object
Hmm you are right, it IS really slow :-) Maybe you can optimize your replace code to be faster, by explicitly checking for "{\object" or "{\pict" phrases, then search their ending by finding an approriate "}" using two regular expressions:
pragma runLim, 10000
Regexp reObj = regexp "({\\\\object)|({\\\\pict)"
Regexp reBrace = regexp "([{}])"
Buffer b = create();
b = richTextWithOle (current Object)."Object Text"
// print tempStringOf b
// halt
int pos = 0;
int iLen = length b
int oleStart = 0
int oleEnd = 0
Buffer result = create()
int nextOle = -1
while (pos < iLen) {
if (nextOle < pos) {
// find the next ole object
if ( search (reObj, b, pos) ) {
oleStart = oleStart + start 0
int braceLevel = 1
oleEnd = oleStart+1
print "Searching End of OLE from:" oleStart "\n"
while (braceLevel > 0) {
if ( search (reBrace, b, oleEnd) ) {
string found = b[oleEnd+(start 0):oleEnd+(end 0)]
print "Found brace at:" (start 0) "(" found ")\n"
oleEnd = (end 0)+1+oleEnd
print "oleEnd:" (oleEnd) "-" found "\n"
if found == "{" then braceLevel++
if found == "}" then braceLevel--
} else break
}
nextOle = oleStart
} else { nextOle = iLen + 1 }
print "Found OLE object: " oleStart "\n"
}
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
// your replace code here:
pos ++
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: identify OLE-position in object Mathias Mamsch - Tue Sep 14 13:44:07 EDT 2010
Hmm you are right, it IS really slow :-) Maybe you can optimize your replace code to be faster, by explicitly checking for "{\object" or "{\pict" phrases, then search their ending by finding an approriate "}" using two regular expressions:
pragma runLim, 10000
Regexp reObj = regexp "({\\\\object)|({\\\\pict)"
Regexp reBrace = regexp "([{}])"
Buffer b = create();
b = richTextWithOle (current Object)."Object Text"
// print tempStringOf b
// halt
int pos = 0;
int iLen = length b
int oleStart = 0
int oleEnd = 0
Buffer result = create()
int nextOle = -1
while (pos < iLen) {
if (nextOle < pos) {
// find the next ole object
if ( search (reObj, b, pos) ) {
oleStart = oleStart + start 0
int braceLevel = 1
oleEnd = oleStart+1
print "Searching End of OLE from:" oleStart "\n"
while (braceLevel > 0) {
if ( search (reBrace, b, oleEnd) ) {
string found = b[oleEnd+(start 0):oleEnd+(end 0)]
print "Found brace at:" (start 0) "(" found ")\n"
oleEnd = (end 0)+1+oleEnd
print "oleEnd:" (oleEnd) "-" found "\n"
if found == "{" then braceLevel++
if found == "}" then braceLevel--
} else break
}
nextOle = oleStart
} else { nextOle = iLen + 1 }
print "Found OLE object: " oleStart "\n"
}
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
// your replace code here:
pos ++
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
thanks for your comment... I am still trying... :-) |
Re: identify OLE-position in object Mathias Mamsch - Tue Sep 14 13:44:07 EDT 2010
Hmm you are right, it IS really slow :-) Maybe you can optimize your replace code to be faster, by explicitly checking for "{\object" or "{\pict" phrases, then search their ending by finding an approriate "}" using two regular expressions:
pragma runLim, 10000
Regexp reObj = regexp "({\\\\object)|({\\\\pict)"
Regexp reBrace = regexp "([{}])"
Buffer b = create();
b = richTextWithOle (current Object)."Object Text"
// print tempStringOf b
// halt
int pos = 0;
int iLen = length b
int oleStart = 0
int oleEnd = 0
Buffer result = create()
int nextOle = -1
while (pos < iLen) {
if (nextOle < pos) {
// find the next ole object
if ( search (reObj, b, pos) ) {
oleStart = oleStart + start 0
int braceLevel = 1
oleEnd = oleStart+1
print "Searching End of OLE from:" oleStart "\n"
while (braceLevel > 0) {
if ( search (reBrace, b, oleEnd) ) {
string found = b[oleEnd+(start 0):oleEnd+(end 0)]
print "Found brace at:" (start 0) "(" found ")\n"
oleEnd = (end 0)+1+oleEnd
print "oleEnd:" (oleEnd) "-" found "\n"
if found == "{" then braceLevel++
if found == "}" then braceLevel--
} else break
}
nextOle = oleStart
} else { nextOle = iLen + 1 }
print "Found OLE object: " oleStart "\n"
}
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
// your replace code here:
pos ++
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hey...
...
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
...
|
Re: identify OLE-position in object Mr.Ferrari - Wed Oct 06 09:43:12 EDT 2010
Hey...
...
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
...
Not sure. It used to work. Can you attach the richText you are trying this with in a file and post the code you are using (if you modified it)? print richTextWithOle (current Object)."Object Text"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: identify OLE-position in object Mr.Ferrari - Wed Oct 06 09:43:12 EDT 2010
Hey...
...
// skip ole object
if (nextOle == pos) {
pos = oleEnd; continue
print "Skipping OLE object: " oleEnd "\n"
}
...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: identify OLE-position in object Mathias Mamsch - Wed Oct 06 10:06:25 EDT 2010
Not sure. It used to work. Can you attach the richText you are trying this with in a file and post the code you are using (if you modified it)? print richTextWithOle (current Object)."Object Text"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I am getting an error: null buffer parameter was passed into argument position 1 argh... |
Re: identify OLE-position in object Mr.Ferrari - Wed Oct 06 10:30:05 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |